package com.gitee.tianchaohongyu.jdcl.core;

import lombok.Getter;
import lombok.Setter;

/**
 * 数据清洗异常
 */
public class CleanException extends RuntimeException {

  /** 异常消息 */
  private String msg;

  /** 代码位置名称 */
  @Getter
  @Setter
  private String codeName;


  public CleanException() {
  }

  public CleanException(String message) {
    super();
    this.msg = message;
  }

  public CleanException(String codeName, String message) {
    this(message);
    setCodeName(codeName);
  }

  public CleanException(String message, Throwable cause) {
    super(cause);
    this.msg = message;
  }

  public CleanException(String codeName, String message, Throwable cause) {
    this(message, cause);
    setCodeName(codeName);
  }


  @Override
  public String getMessage() {
    StringBuilder stringBuilder = new StringBuilder();
    if (codeName != null) stringBuilder.append("在(").append(codeName).append("):");
    if (msg != null) stringBuilder.append(msg);
    return stringBuilder.toString();
  }
}
